$(function() {


var e = $("#main");
  var a = new Handsontable(e.get(0), {
    data: [
      ["Java", "1", "降", "-0.01%"],
      ["C", "2", "升", "+2.44%"],
      ["Python", "3", "升", "+1.41%"],
      ["C++", "4", "降", "-2.58%"],
      ["C#", "5", "升", "+2.07%"],
      ["Visual Basic Net", "6", "降", "-1.17%"],
      ["JavaScript", "7", "降", "-0.85%"]
    ],
    contextMenu: !0,//右键菜单
    manualRowResize: !0,
    manualColumnResize: !0,
    rowHeaders: 0,
    className: "htCenter",
    colHeaders: ["语言名称", "排名", "升或降", "变化幅度"]
  });
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main2'));
        
        let xData=[0],
            yData=[0];
        for(let i=0.1; i<=1; i+=0.1) {
          xData.push(Math.round(i*10)/10);
          yData.push(h(i));
        }
        function h(p) {
          let a = -1*p*Math.log2(p)-(1-p)*Math.log2(1-p);
          return (Math.round(a*100)/100);
        }

        // 指定图表的配置项和数据
        var option = {
            title: {
                text: '二进制熵函数曲线'
            },
            tooltip: {},
            legend: {
                data:['信息量']
            },
            xAxis: {
                data: xData
                //data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '信息量',
                //type: 'bar',//柱状图
                type: "line",
                smooth: true,//平滑的折线图
                //data: [5, 20, 36, 10, 10, 20]
                data: yData
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
});
